package com.hytc.mymall.utils;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Environment;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.widget.TextView;

import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Date;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;

public class BaseTools
{
  public static MyCountDownTimer timer;
  
  public static String ToDBC(String paramString)
  {
    char[] arrayOfChar = paramString.toCharArray();
    int i = 0;
    if (i >= arrayOfChar.length) {
      return new String(arrayOfChar);
    }
    if (arrayOfChar[i] == '　') {
      arrayOfChar[i] = ' ';
    }
    for (;;)
    {
      i++;
      break;
//      if ((arrayOfChar[i] > 65280) && (arrayOfChar[i] < 65375)) {
//        arrayOfChar[i] = ((char)(arrayOfChar[i] - 65248));
//      }
    }
    return null;
  }
  
  public static int dip2px(Context paramContext, float paramFloat)
  {
    return (int)(0.5F + paramFloat * paramContext.getResources().getDisplayMetrics().density);
  }
  
  public static int dpToPx(Resources paramResources, int paramInt)
  {
    return (int)TypedValue.applyDimension(1, paramInt, paramResources.getDisplayMetrics());
  }
  
  public static String formatAmount(Object paramObject)
  {
    return new DecimalFormat("0.00").format(paramObject);
  }
  
  public static String formatDouble(double paramDouble)
  {
    return new DecimalFormat("#0.00").format(paramDouble);
  }
  
  public static String formatMoney(Object paramObject)
  {
    DecimalFormat localDecimalFormat = new DecimalFormat("0.00");
    String str = localDecimalFormat.format(paramObject);
    str.length();
    if (str.length() > 7) {
      return localDecimalFormat.format(Math.floor(Double.valueOf(str).doubleValue() / 100.0D) / 100.0D) + "万";
    }
    return str;
  }
  
  public static <T> T getBean(Context paramContext, String paramString, Class<T> paramClass)
  {
    try
    {
      Object localObject = GsonUtils.json2Bean(readTextFile(paramContext.getAssets().open(paramString)), paramClass);
      return (T) localObject;
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
    }
    return null;
  }
  
  public static String getData(long paramLong)
  {
    Date localDate = new Date(paramLong);
    return new SimpleDateFormat("yyyyMMdd").format(localDate);
  }
  
  public static String getData2(long paramLong)
  {
    Date localDate = new Date(paramLong);
    return new SimpleDateFormat("yyyy-MM-dd").format(localDate);
  }
  
  @SuppressLint({"NewApi"})
  public static String getFileRoot(Context paramContext)
  {
    if (Environment.getExternalStorageState().equals("mounted"))
    {
      File localFile = paramContext.getExternalFilesDir(null);
      if (localFile != null) {
        return localFile.getAbsolutePath();
      }
    }
    return paramContext.getFilesDir().getAbsolutePath();
  }
  
  public static void getRegistVerifyCode(final Context paramContext, final TextView paramTextView, String paramString1, String paramString2, int paramInt, String paramString3)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("mobilenumber", paramString1);
    localHashMap.put("sendtype", paramString2);
    localHashMap.put("usertype", paramInt);
    localHashMap.put("usernumber", paramString3);
//    OkHttpClientManager.postAsyn("http://www.51ydgy.com/appcommon/regSendVerifyCode", new StringPopCallBack(paramContext, true)
//    {
//      @Override
//      public void onBeforeRequest(Request paramRequest) {
//
//      }
//
//      @Override
//      public void onFailure(Request paramRequest, IOException paramIOException) {
//
//      }
//
//      public void onResponse(String paramAnonymousString)
//      {
//        try
//        {
//          JSONObject localJSONObject = new JSONObject(paramAnonymousString);
//          String str1 = localJSONObject.getString("code");
//          String str2 = localJSONObject.getString("msg");
//          if (str1.equals("0"))
//          {
//            paramTextView.setEnabled(false);
//            BaseTools.timer = new MyCountDownTimer(120000L, 1000L, paramTextView);
////            BaseTools.timer.start();
//            ToastUtils.showToastWithImage(paramContext, str2, true);
//            return;
//          }
//          ToastUtils.showToastWithImage(paramContext, str2, false);
//          return;
//        }
//        catch (JSONException localJSONException)
//        {
//          ToastUtils.showToastWithImage(paramContext, localJSONException.toString(), false);
//          localJSONException.printStackTrace();
//        }
//      }
//    }, localHashMap);
  }
  
  public static int getStatusBarHeight(Context paramContext)
  {
    int i = paramContext.getResources().getIdentifier("status_bar_height", "dimen", "android");
    int j = 0;
    if (i > 0) {
      j = paramContext.getResources().getDimensionPixelSize(i);
    }
    return j;
  }
  
  public static void getVerifyCode(final Context paramContext, final TextView paramTextView, String paramString1, String paramString2, int paramInt)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("mobilenumber", paramString1);
    localHashMap.put("sendtype", paramString2);
    localHashMap.put("usertype", paramInt);
//    OkHttpClientManager.postAsyn("http://www.51ydgy.com/appcommon/sendVerifyCode", new StringPopCallBack(paramContext, true)
//    {
//      @Override
//      public void onBeforeRequest(Request paramRequest) {
//
//      }
//
//      @Override
//      public void onFailure(Request paramRequest, IOException paramIOException) {
//
//      }
//
//      public void onResponse(String paramAnonymousString)
//      {
//        try
//        {
//          JSONObject localJSONObject = new JSONObject(paramAnonymousString);
//          String str1 = localJSONObject.getString("code");
//          String str2 = localJSONObject.getString("msg");
//          if (str1.equals("0"))
//          {
//            paramTextView.setEnabled(false);
//            BaseTools.timer = new MyCountDownTimer(120000L, 1000L, paramTextView);
////            BaseTools.timer.start();
//            ToastUtils.showToastWithImage(paramContext, str2, true);
//            return;
//          }
//          ToastUtils.showToastWithImage(paramContext, str2, false);
//          return;
//        }
//        catch (JSONException localJSONException)
//        {
//          localJSONException.printStackTrace();
//        }
//      }
//    }, localHashMap);
  }
  
  public static String getVersion(Context paramContext)
  {
    try
    {
      PackageInfo localPackageInfo = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 0);
      String str = "V" + localPackageInfo.versionName;
      return str;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return "";
  }
  
  public static final int getWindowsHeight(Activity paramActivity)
  {
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    paramActivity.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
    return localDisplayMetrics.heightPixels;
  }
  
  public static final int getWindowsWidth(Activity paramActivity)
  {
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    paramActivity.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
    return localDisplayMetrics.widthPixels;
  }
  
  public static boolean isEmail(String paramString)
  {
    if (TextUtils.isEmpty("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")) {
      return false;
    }
    return paramString.matches("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
  }
  
  public static boolean isMobileNO(String paramString)
  {
    if (TextUtils.isEmpty(paramString)) {
      return false;
    }
    return paramString.matches("[1][0123456789]\\d{9}");
  }
  
  public static boolean isNetworkAvailable(Context paramContext)
  {
    ConnectivityManager localConnectivityManager = (ConnectivityManager)paramContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (localConnectivityManager == null) {}
    for (;;)
    {
      NetworkInfo[] arrayOfNetworkInfo = localConnectivityManager.getAllNetworkInfo();
      if (arrayOfNetworkInfo != null) {
        for (int i = 0; i < arrayOfNetworkInfo.length; i++) {
          if (arrayOfNetworkInfo[i].getState() == NetworkInfo.State.CONNECTED) {
            return true;
          }
        }
      }
      return false;
    }

  }
  
  public static boolean isNormalUsername(String paramString)
  {
    return (!paramString.contains("\\")) && (!paramString.contains("/")) && (!paramString.contains("?")) && (!paramString.contains(":")) && (!paramString.contains("*")) && (!paramString.contains("<")) && (!paramString.contains(">")) && (!paramString.contains("|")) && (!paramString.contains("\""));
  }
  
  public static boolean isPsw(String paramString)
  {
    if (TextUtils.isEmpty("^[a-zA-Z0-9]{6,16}$")) {
      return false;
    }
    return paramString.matches("^[a-zA-Z0-9]{6,16}$");
  }
  
  public static boolean isRealName(String paramString)
  {
    if (TextUtils.isEmpty("[a-zA-Z0-9一-龥]+")) {
      return false;
    }
    return paramString.matches("[a-zA-Z0-9一-龥]+");
  }
  
  public static boolean isReffer(String paramString)
  {
    if (TextUtils.isEmpty("[a-zA-Z0-9]+")) {
      return false;
    }
    return paramString.matches("[a-zA-Z0-9]+");
  }
  
  public static boolean isSecondLevelPsw(String paramString)
  {
    if (TextUtils.isEmpty("^\\d{6}$")) {
      return false;
    }
    return paramString.matches("^\\d{6}$");
  }
  
  public static boolean isUserNumber(String paramString)
  {
    if (TextUtils.isEmpty("^[A,M,B]+[0-9]+$")) {
      return false;
    }
    return paramString.matches("^[A,M,B]+[0-9]+$");
  }
  
  public static boolean isUsername(String paramString)
  {
    int i = paramString.length();
    return (i > 0) && (i <= 13);
  }
  
  public static int px2dip(Context paramContext, float paramFloat)
  {
    return (int)(0.5F + paramFloat / paramContext.getResources().getDisplayMetrics().density);
  }

  public static String readTextFile(InputStream paramInputStream)
  {
    int i;
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    byte[] arrayOfByte = new byte[1024];
    for (;;)
    {
      try
      {
        //test

        i = paramInputStream.read(arrayOfByte);
        if (i != -1) {
          continue;
        }
        localByteArrayOutputStream.close();
        paramInputStream.close();
      }
      catch (IOException localIOException)
      {
//        int i;
        continue;
      }
      localByteArrayOutputStream.write(arrayOfByte, 0, i);
      return localByteArrayOutputStream.toString();

    }
  }
  
  public static void saveFile(Bitmap paramBitmap, String paramString1, String paramString2)
  {
    try
    {
      File localFile = new File(paramString1);
      if (!localFile.exists()) {
        localFile.mkdir();
      }
      BufferedOutputStream localBufferedOutputStream = new BufferedOutputStream(new FileOutputStream(new File(localFile, paramString2)));
      paramBitmap.compress(CompressFormat.PNG, 80, localBufferedOutputStream);
      localBufferedOutputStream.flush();
      localBufferedOutputStream.close();
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }
  
  public static void setStatusBar(Activity paramActivity)
  {
    if (Build.VERSION.SDK_INT >= 19)
    {
//      paramActivity.getWindow().addFlags(67108864);
//      SystemBarTintManager localSystemBarTintManager = new SystemBarTintManager(paramActivity);
//      localSystemBarTintManager.setStatusBarTintEnabled(true);
//      localSystemBarTintManager.setNavigationBarTintEnabled(true);
//      localSystemBarTintManager.setStatusBarTintResource(2131165197);
    }
  }
  
  public static String setTextMoneyUtil(String paramString)
  {
    if ((paramString == null) || (paramString.equals(""))) {
      return "0.00 元";
    }
    return formatMoney(Double.valueOf(Double.parseDouble(paramString))) + " 元";
  }
  
  public static String setTextUtil(String paramString1, String paramString2)
  {
    if (TextUtils.isEmpty(paramString1)) {
      return paramString2;
    }
    return paramString1;
  }
}



/* Location:           C:\Users\Joker\Desktop\classes_dex2jar.jar

 * Qualified Name:     com.sz.ydgy.utils.BaseTools

 * JD-Core Version:    0.7.0.1

 */